<template>
  <div class="formDiv">
    <el-card class="box-card">
      <div class="back">
        <div>
          <el-button
            class="submission priamry_border"
            style="display: flex; float: right"
            @click="back()"
            >返回</el-button
          >
        </div>
      </div>
      <el-form
        ref="ruleForm"
        :model="ruleForm"
        clearable
        label-width="110px"
        class="formArea"
      >
        <el-row>
          <el-col :span="12"
            ><div>
              <!-- 酒店名称 -->
              <el-form-item label="酒店名称：">
                <span v-html="ruleForm.jdName || '无'"></span>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <!-- 房间号 -->
              <el-form-item label="房间号：">
                <span v-html="ruleForm.fjNumber || '无'"></span>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-divider></el-divider>
        <el-row>
          <el-col :span="12"
            ><div>
              <!-- 房型 -->
              <el-form-item label="房型：">
                <span v-html="ruleForm.fxName || '无'"></span>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <!-- 房间名称 -->
              <el-form-item label="房间名称：">
                <span v-html="ruleForm.fjName || '无'"></span>
              </el-form-item></div
          ></el-col>
        </el-row>

        <el-row>
          <el-col :span="12"
            ><div>
              <!-- 房间wifi名称 -->
              <el-form-item label="wifi名称：" class="roomStatus">
                <span v-html="ruleForm.fjWifiName || '无'"></span>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <!-- 房间wifi密码 -->
              <el-form-item label="wifi密码：">
                <span v-html="ruleForm.fjWifiPwd || '无'"></span>
              </el-form-item></div
          ></el-col>
        </el-row>

        <el-row>
          <el-col :span="12"
            ><div>
              <!-- 房间价格 -->
              <el-form-item label="房间价格：">
                <span v-html="ruleForm.fjPrice || '无'"></span>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <!-- 房间楼层 -->
              <el-form-item label="房间楼层：">
                <span v-html="ruleForm.fjFloor || '无'"></span>
              </el-form-item></div
          ></el-col>
        </el-row>

        <el-row>
          <el-col :span="12"
            ><div>
              <!-- 房间密码 -->
              <el-form-item label="房间密码：">
                <span v-html="ruleForm.fjPwd || '无'"></span>
              </el-form-item></div
          ></el-col>
          <el-col :span="12"
            ><div>
              <!-- 房间入住状态 -->
              <el-form-item label="房间状态：" prop="status">
                <el-tooltip
                  effect="dark"
                  :content="ruleForm.status == '0' ? '未入住' : '已入住'"
                  placement="right"
                >
                  <el-switch
                    v-model="ruleForm.status"
                    :active-value="1"
                    :inactive-value="0"
                    disabled
                  >
                  </el-switch>
                </el-tooltip>
              </el-form-item></div
          ></el-col>
        </el-row>
        <el-divider></el-divider>
        <el-row>
          <el-col :span="12"
            ><div>
              <!-- 房间是否展示 -->
              <el-form-item label="房间展示：" prop="isShow">
                <el-tooltip
                  effect="dark"
                  :content="ruleForm.isShow == '0' ? '不展示' : '展示'"
                  placement="right" 
                >
                  <el-switch
                    v-model="ruleForm.isShow"
                    :active-value="1"
                    :inactive-value="0"
                     disabled
                  >
                  </el-switch>
                </el-tooltip>
              </el-form-item></div
          ></el-col>
        </el-row>
        <div class="picUpload">
          <!-- 房间图片 -->
          <el-form-item label="房间图片：">
            <div class="upLoadPicBox">
              <div
                v-for="(item, index) in ruleForm.fjImg"
                :key="index"
                class="pictrue"
                draggable="true"
              >
                <img :src="item" />
              </div>
               <div
                v-if="ruleForm.fjImg != [] && !isDisabled"
                @click="modalPicTap('2')"
              >
              </div>
            </div>
          </el-form-item>
        </div>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import { getRoomApi } from "@/api/roomInformation";
export default {
  created() {
    this.getRoom(); // 根据房间 id 查询房间
  },
  data() {
    return {
      isDisabled: this.$route.params.isDisabled === "1" ? true : false,
      options4: [], //wifi列表
      options3: [], //房型数据
      //查询所有酒店的房间
      tableForm: {
        limit: 10,
        page: 1,
      },
      options: [], //所有酒店名称
      //表单
      ruleForm: {
        fjFloor: "", //房间楼层
        fxName: "", //房型名称
        jdName: "", //酒店名称
        fjName: "", //房间名称
        fjNumber: "", //房间号
        fjPrice: "", //房间价格
        fjPwd: "", //房间密码
        fjWifiName: "", //房间wifi名称
        fjWifiPwd: "", //房间wifi密码
        fjImg: [], //房间图片
        jdId: "", //酒店id
        id: 0,
        isDel: 0,
        isShow: "",//房间是否显示
        sort: 0,
        status: "", //房间状态
      },
    };
  },
  methods: {
    //返回上一页
    back() {
      this.$router.push("/amszs/msroom/index");
    },
    // 2.根据房间 id 查询房间
    async getRoom() {
      const id = JSON.parse(sessionStorage.getItem("data"));
      const res = await getRoomApi({ id });
      this.ruleForm = res;
    },
  },
};
</script>


<style lang="scss" scoped>
.formDiv {
  margin-top: 40px;
  margin-left: 30px;
  .back {
    width: 100%;
    height: 40px;
    display: flex;
    justify-content: end;
  }
  .formArea {
    padding: 0 30px;
    .picUpload {
      width: 800px;
      height: 100px;
      .upLoadPicBox {
        display: flex;
        width: 800px;
        height: 70px;
      }
    }
    .pictrue {
      width: 60px;
      height: 60px;
      border: 1px dotted rgba(0, 0, 0, 0.1);
      margin-right: 10px;
      position: relative;
      cursor: pointer;
    }
  }
  .el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
  .buttons {
    width: 100%;
    height: 50px;
    padding-left: 155px;
  }
  .el-input__inner {
    width: 30vw;
  }
  .el-select .el-select--medium {
    width: 40vw;
  }
}
.picture {
  width: 100px;
  height: 100px;
  // background-color: pink;
  border: 1px solid black;
}
.upload {
  width: 80px;
  height: 80px;
  text-align: center;
  line-height: 80px;
  // background-color: pink;
  border: 1px solid #fff;
}
</style>